package proceso;

import disco.CFQRequest;
import java.util.Queue;
import java.util.concurrent.SynchronousQueue;

public class ColaRequest {

    int n = 0;
    Queue<disco.CFQRequest> colaRequest;

    public ColaRequest() {
        colaRequest = new SynchronousQueue<CFQRequest>();
    }

    public synchronized disco.CFQRequest get() {
        if (colaRequest.size() <= 0) {
            try {
                wait();

            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
      
        return colaRequest.remove();        
    }

    synchronized void put(disco.CFQRequest cfqRequest) {
        //TODO revisar el 10
        System.out.println("Entra");
        if (colaRequest.size() > 10) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        colaRequest.add(cfqRequest);
        System.out.println("Colocado cfqRequest en colaRequest");
        notify();
    }

    
}
